home *** CD-ROM | disk | FTP | other *** search
/ CD Classic / CD CLASSIC #1.iso / mlink / host.msl < prev    next >
Text File  |  1992-04-12  |  14KB  |  436 lines

  1. ' Host mode script
  2. ' Access levels are:    3 - Sysop
  3. '                       2 - user can access any directory
  4. '                       1 - user can access only current directory
  5. PUSH
  6. SET ECHO ON
  7. SET TEXTWRAP ON
  8. SET HOSTECHO ON
  9. SET INCRLF ON
  10. SET OUTCRLF ON
  11. SET CARRIERDETECT ON
  12.  
  13. upload_dir$ = uploaddirectory
  14. default_dir$ = defaultdirectory
  15. file_spec$ = filespec
  16.  
  17.  
  18. cr$ = "^M"
  19. cr2$ = "^M^M"
  20. cr3$ = "^M^M^M"
  21. cr4$ = "^M^M^M^M"
  22. cr5$ = "^M^M^M^M^M"
  23. newpage$ = cr5$+cr5$+cr5$+cr5$+cr5$
  24.  
  25. Header$   = "                   Host Mode"
  26.  
  27. welcome1$ = "                 ***********************************"+cr$
  28. welcome2$ = "                 *        Microlink Host Mode      *"+cr$
  29. welcome3$ = "                 *      Press ENTER to Continue    *"+cr$
  30. welcome4$ = "                 ***********************************"+cr5$
  31.  
  32. continue = 1
  33. max_lines = 20
  34.  
  35.  
  36. WHILE continue=1
  37.     if ChangeDirectory(default_dir$) > 0 then
  38.       mprint "Invalid default directory"
  39.       beep
  40.       sleep 5
  41.       continue = 0
  42.       GOTO force_hangup
  43.     endif
  44.  
  45.     current_dir$ = default_dir$
  46.  
  47.     ONERROR force_hangup
  48.     AUTOANSWER
  49.  
  50.  
  51.     ' Computer answered phone
  52.  
  53.     sleep 5
  54.     IF Connected = 0 Then
  55.      goto force_hangup
  56.     endif
  57.     RPRINT newpage$
  58.     RPRINT welcome1$
  59.     RPRINT welcome2$
  60.     RPRINT welcome3$
  61.     RINPUT welcome4$,temp$
  62.     Rprint cr4$
  63.  
  64.     ' Prompts to enter password
  65.     logon_ok = 0
  66.     set error off
  67.     FOR i = 1 TO 3
  68.         onerror skipsignon
  69.         RINPUT cr$+"Enter FIRST name: ", first$
  70.         RINPUT cr$+"Enter LAST name: ", last$
  71.         SET HOSTECHO OFF
  72.         RINPUT cr$+"Enter PASSWORD: ", password$
  73.         set error off
  74.         SET HOSTECHO ON
  75.         logon_ok = VerifyUser(first$, last$, password$)
  76.           IF logon_ok > 1  THEN
  77.             IF OPENHOST = 1 THEN
  78.                 onerror skipnew
  79.                    rprint cr2$+"              N E W   U S E R"+cr2$
  80.                 Rprint cr$+"First Name: "+first$
  81.                    Rprint cr$+"Last Name: "+last$
  82.                    RINPUT cr$+"Correct? ", Temp$
  83.                    logon_ok = 0
  84.                    IF upper(Temp$) = "Y" THEN
  85.                      IF Adduser(first$, last$, password$, 1) > 0 THEN
  86.                            RPRINT cr2$+"Unable To Add User At This Time"
  87.                            logon_ok = 1
  88.                      ENDIF
  89.                      EXIT
  90.                 ENDIF
  91.                 skipnew:
  92.               ELSE
  93.                  RPRINT cr2$+"Invalid logon attempt!"
  94.                   IF i < 3 THEN
  95.                      RPRINT cr$+"There are " + String(3 - i) + " attempts left."
  96.                 ENDIF
  97.               ENDIF
  98.         ELSE
  99.          IF logon_ok = 1  THEN
  100.             RPRINT cr$+"Invalid logon attempt!"
  101.             IF i < 3 THEN
  102.               RPRINT cr$+"There are " + String(3 - i) + " attempts left." + cr$
  103.             ENDIF
  104.          ELSE
  105.            EXIT
  106.          ENDIF
  107.         ENDIF
  108.         skipsignon:
  109.     NEXT
  110.  
  111.     IF logon_ok > 0 THEN
  112.         RPRINT cr2$+"Unable to validate user!"
  113.         RPRINT cr2$+"Hanging up!"
  114.         goto force_hangup
  115.     else
  116.         continue_commands = 1
  117.         access_level = ExtractUserLevel(first$, last$)
  118.         rprint cr4$
  119.     endif
  120.     WHILE continue_commands = 1
  121.         if Connected = 0 then
  122.                EXIT
  123.         endif
  124.         RPRINT cr2$+"         Host Mode Processor"+cr2$
  125.         RPRINT cr$ + "[F]File Directory    [D]Download    [U]Upload"
  126.                  ' Level 2 or 3
  127.         IF access_level > 1  THEN
  128.             RPRINT cr$ + "[CD]Change Directory [FS]File Specification"
  129.         ENDIF
  130.  
  131.         ' Level 3 only
  132.         IF access_level > 2 then
  133.             RPRINT cr$ + "[AU]Add User         [CU]Change User"
  134.             RPRINT cr$ + "[DU]Delete User      [S]ShutDown"
  135.         ENDIF
  136.  
  137.         RPRINT cr$ + "[G]Goodbye"
  138.  
  139.         ' Wait for command
  140.         RINPUT cr2$+current_dir$ + "> ", tempcommand$
  141.         command$ = upper(tempcommand$)
  142.  
  143.         ' Exit System
  144.         if len(command$) = 1 then
  145.             IF command$ = "G"  THEN
  146.                 RPRINT cr$ + "Thanks for calling " + first$ + "!" + cr$
  147.                 continue_commands = 0
  148.                 SLEEP 2
  149.             ENDIF
  150.  
  151.                     ' List Files
  152.             IF command$ = "F" THEN
  153.                 RPRINT cr4$
  154.                 RPRINT "Directory listing of: " + current_dir$ + cr2$
  155.                 ChangeDirectory(current_dir$)
  156.                    filename$ = GetFirstDirEntry(current_dir$, file_spec$)
  157.                 WHILE Len(filename$) > 0
  158.                     IF Connected = 0 Then
  159.                            EXIT
  160.                     endif
  161.                     FOR i = 1 to max_lines
  162.                         RPRINT filename$ + cr$
  163.                         filename$ = GetNextDirEntry()
  164.                         IF Len(filename$) = 0 THEN
  165.                             EXIT
  166.                         ENDIF
  167.                     NEXT
  168.                     IF LEN(filename$) > 0 THEN
  169.                           Rinput cr$+"List paused.  Press ENTER to continue.",temp$
  170.                           IF "C" = upper(temp$) THEN
  171.                                exit
  172.                             ENDIF
  173.                             rprint cr4$
  174.                     ENDIF
  175.                 WEND
  176.  
  177.                 RINPUT cr$+"End of List.   Press ENTER to Continue",temp$
  178.                 rprint cr4$
  179.             ENDIF
  180.  
  181.             ' Download a File
  182.             IF command$ = "D" THEN
  183.                 rprint cr4$
  184.                 WHILE 1 = 1
  185.                     IF Connected = 0 Then
  186.                            EXIT
  187.                     endif
  188.                     RPRINT cr$+Header$+cr3$
  189.                     RPRINT cr$+"Available download file transfer protocols:" + cr2$
  190.                     RPRINT "[X]..XMODEM Checksum" + cr$
  191.                     RPRINT "[C]..XMODEM CRC" + cr$
  192.                     RPRINT "[Y]..YMODEM 1K" + cr$
  193.                     RPRINT "[YB].YMODEM Batch" + cr$
  194.                     RPRINT "[YG].YMODEM G" + cr$
  195.                     RPRINT "[Z]..ZMODEM" + cr$
  196.                     RPRINT "[E]..Cancel" + cr$
  197.                     RINPUT "Select protocol: ", tempchoice$
  198.                     choice$ = upper(tempchoice$)
  199.                     if len(choice$) = 1 then
  200.                           IF choice$ = "E" THEN
  201.                             EXIT
  202.                         ENDIF
  203.                         IF choice$ = "X" THEN
  204.                             set protocol XMODEM
  205.                             EXIT
  206.                         ENDIF
  207.                         IF choice$ = "C" THEN
  208.                             set protocol XMODEMCRC
  209.                             EXIT
  210.                         ENDIF
  211.                         IF choice$ = "Y" THEN
  212.                             set protocol YMODEM
  213.                             EXIT
  214.                         ENDIF
  215.                         IF choice$ = "Z" THEN
  216.                             set protocol ZMODEM
  217.                             EXIT
  218.                         ENDIF
  219.                     endif
  220.                     if len(choice$) = 2 then
  221.                         IF choice$ = "YB" THEN
  222.                             set protocol YMODEMB
  223.                             EXIT
  224.                         ENDIF
  225.                         IF choice$ = "YG" THEN
  226.                             set protocol YMODEMG
  227.                             EXIT
  228.                         ENDIF
  229.                     ENDIF
  230.                     rprint cr2$+"Invalid Selection"+cr2$
  231.                 WEND
  232.                    IF choice$ = "E" THEN
  233.                     rprint "Canceled!"+cr$
  234.                    ELSE
  235.                        ChangeDirectory(current_dir$)
  236.                       RINPUT cr2$+"Enter Filename: ", transfer_file$
  237.                       is_ok = DoesFileExist(transfer_file$)
  238.                       IF is_ok = 1 THEN
  239.                          RPRINT cr$+"File " + transfer_file$ + " was not found." + cr$
  240.                          RPRINT "File transfer canceled!" + cr$
  241.                       ELSE
  242.                          RPRINT cr$+"Downloading " + transfer_file$ + cr$
  243.                          ONERROR snderr
  244.                         SEND transfer_file$
  245.                         sleep 3
  246.                          rprint cr$+"File Transfer Successful"
  247.                          goto sndok
  248.                          snderr:
  249.                               rprint cr2$+"Error Downloading File"
  250.                            rinput cr$+"Hit ENTER to Continue",temp$
  251.                          sndok:
  252.                          set error off
  253.                        ENDIF
  254.                    ENDIF
  255.             ENDIF
  256.         ' Receive a File
  257.             IF command$ = "U" THEN
  258.                 rprint cr4$
  259.                 WHILE 1 = 1
  260.                     IF Connected = 0 Then
  261.                            EXIT
  262.                     endif
  263.                     RPRINT cr$+Header$+cr3$
  264.                     RPRINT "Available Upload file transfer protocols:" + cr2$
  265.                     RPRINT "[X]..XMODEM Checksum" + cr$
  266.                     RPRINT "[C]..XMODEM CRC" + cr$
  267.                     RPRINT "[Y]..YMODEM 1K" + cr$
  268.                     RPRINT "[YB].YMODEM Batch" + cr$
  269.                     RPRINT "[YG].YMODEM G" + cr$
  270.                     RPRINT "[Z]..ZMODEM" + cr$
  271.                     RPRINT "[E]..Exit" + cr$
  272.                     RINPUT "Select protocol: ", tempchoice$
  273.                     choice$ = upper(tempchoice$)
  274.                     if len(choice$) = 1 then
  275.                           IF choice$ = "E" THEN
  276.                             EXIT
  277.                         ENDIF
  278.                         IF choice$ = "X" THEN
  279.